package com.shop.utils;

import com.jfinal.config.Constants;
import com.jfinal.config.Handlers;
import com.jfinal.config.Interceptors;
import com.jfinal.config.JFinalConfig;
import com.jfinal.config.Plugins;
import com.jfinal.config.Routes;
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
import com.jfinal.plugin.c3p0.C3p0Plugin;
import com.jfinal.render.ViewType;
import com.shop.bean.AddressBean;
import com.shop.bean.DpglBean;
import com.shop.bean.LiuyanBean;
import com.shop.bean.NzcpdlBean;
import com.shop.bean.NzcpxlBean;
import com.shop.bean.OrderProductBean;
import com.shop.bean.PLiuyanBean;
import com.shop.bean.POrderBean;
import com.shop.bean.ProPicsBean;
import com.shop.bean.ProductBean;
import com.shop.bean.ShopcartBean;
import com.shop.bean.ShrmessBean;
import com.shop.bean.UserBean;
import com.shop.bean.UserInfoBean;
import com.shop.bean.XfjfBean;
import com.shop.bean.ZhifuBean;
import com.shop.controller.CCartController;
import com.shop.controller.CHelpController;
import com.shop.controller.COrderController;
import com.shop.controller.CUserController;
import com.shop.controller.WelcomeContoller;
import com.shop.controller.admin.AdminController;
import com.shop.controller.admin.CategoriesController;
import com.shop.controller.admin.DpglController;
import com.shop.controller.admin.LiuyanController;
import com.shop.controller.admin.OrderController;
import com.shop.controller.admin.PLiuyanController;
import com.shop.controller.admin.ProductController;
import com.shop.controller.admin.UserController;

public class ConfigUtils extends JFinalConfig{

	/**
	 * 配置 常量�?
	 */
	@Override
	public void configConstant(Constants me) {
		loadPropertyFile("jdbc.properties");
		me.setDevMode(getPropertyToBoolean("devMode", false));
		me.setViewType(ViewType.JSP);
		me.setUrlParaSeparator("-");
		
		me.setError404View("/common/error_404.html");
		me.setError500View("/common/error_500.html");
	}
	/**
	 * 配置 访问路由
	 */
	@Override
	public void configRoute(Routes me) {
		//me.add("ImageValidServlet",ImageValidController.class);
    	me.add("/admin",AdminController.class);
    	me.add("/categories",CategoriesController.class);
    	me.add("/product", ProductController.class);
    	me.add("/dpglmng",DpglController.class);
    	me.add("order",OrderController.class);
    	
    	me.add("/urc",CUserController.class);
    	me.add("/crtc",CCartController.class);
    	me.add("/ordc",COrderController.class);
    	me.add("/wlc",WelcomeContoller.class);
    	
    	me.add("/useropt",UserController.class);
    	me.add("/plyopt",PLiuyanController.class);
    	me.add("/liuyan",LiuyanController.class);
    	
    	me.add("/hpl",CHelpController.class);
	}

	/**
	 * 配置插件
	 */
	@Override
	public void configPlugin(Plugins me) {
		//配置插件
		C3p0Plugin c3p0Plugin = new C3p0Plugin(getProperty("jdbcUrl"), getProperty("user"), getProperty("password"));
		me.add(c3p0Plugin);
		
		ActiveRecordPlugin arp = new ActiveRecordPlugin(c3p0Plugin);
		me.add(arp);
		arp.addMapping("tblyonghu","ucode",UserBean.class);	//映射 
		arp.addMapping("tblnzcpdl", "dlcode", NzcpdlBean.class);
		arp.addMapping("tblnzcpxl","xlcode", NzcpxlBean.class);
		arp.addMapping("tblproduct","pcode", ProductBean.class);
		arp.addMapping("tbldpgl","dpcode",DpglBean.class);
		arp.addMapping("tblyhxinxi","mcode",UserInfoBean.class);
		arp.addMapping("tblpliuyan", "plycode",PLiuyanBean.class);
		arp.addMapping("tblpics", "piccode",ProPicsBean.class);
		arp.addMapping("tbladdress","adcode", AddressBean.class);
		arp.addMapping("tblliuyan", "lycode", LiuyanBean.class);
		arp.addMapping("tblxfjf","xfcode", XfjfBean.class);
		arp.addMapping("tblshopcart","sccode",ShopcartBean.class);
		arp.addMapping("tblorderproduct","opcode", OrderProductBean.class);
		arp.addMapping("tblporder","ocode", POrderBean.class);
		arp.addMapping("tblshrmess","shrcode", ShrmessBean.class);
		arp.addMapping("tblzhifu", "zcode", ZhifuBean.class);
	}

	/**
	 * 配置拦截器
	 */
	@Override
	public void configInterceptor(Interceptors me) {
//		me.add(new ExceptionInterceptor());	
	}

	/**
	 * 配置 处理�?
	 */
	@Override
	public void configHandler(Handlers me) {
		// TODO Auto-generated method stub
		
	}

}
